package org.wltea.analyzer.lucene;

import java.util.Arrays;

import org.apache.lucene.util.AttributeImpl;

public class NatureAttributeImpl extends AttributeImpl implements NatureAttribute, Cloneable{

	private String[] natures;
	
	@Override
	public String[] natures() {
		return natures;
	}

	@Override
	public void setNatures(String[] natures) {
		this.natures = natures;
	}

	@Override
	public void clear() {
		natures = null;
	}

	@Override
	public void copyTo(AttributeImpl target) {
		NatureAttribute t = (NatureAttribute) target;
		t.setNatures(natures);
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + Arrays.hashCode(natures);
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		NatureAttributeImpl other = (NatureAttributeImpl) obj;
		if (this.hashCode()!=natures.hashCode())
			return false;
		return true;
	}

}
